home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / gemfut15.lzh / AESUTRC5.C < prev    next >
C/C++ Source or Header  |  1989-08-27  |  2KB  |  84 lines

  1.  
  2. /**************************************************************************
  3.  *
  4.  * AESFAST PD utilties.
  5.  *
  6.  *  Rectangle utilities 5...
  7.  *    rc_gadjust                (formerly objclg_adjust)
  8.  *    rc_vadjust                (formerly objclv_adjust)
  9.  *
  10.  *  02/28/89 v1.3
  11.  *           Added code to prevent any returned structure element from
  12.  *           being negative, since negative screen indicies do bad things
  13.  *           on a blit, and tend to leave sleeping crashes lurking in the
  14.  *           system if used as the clipping rectangle for objc_draw.
  15.  *************************************************************************/
  16.  
  17. #include <gemfast.h>
  18.  
  19. /*-------------------------------------------------------------------------
  20.  * rc_gadjust - Adjust a GRECT-type rectangle in the x and/or y coordinate.
  21.  *-----------------------------------------------------------------------*/
  22.  
  23. void
  24. rc_gadjust(prect, xadjust, yadjust)
  25.     register GRECT  *prect;
  26.     int             xadjust;
  27.     int             yadjust;
  28. {
  29.     prect->g_x -= xadjust;
  30.     prect->g_y -= yadjust;
  31.     prect->g_w += xadjust * 2;
  32.     prect->g_h += yadjust * 2;
  33.     
  34.     if (prect->g_x < 0) {
  35.         prect->g_x = 0;
  36.     }
  37.     
  38.     if (prect->g_y < 0) {
  39.         prect->g_y = 0;
  40.     }
  41.     
  42.     if (prect->g_w < 0) {
  43.         prect->g_w = 0;
  44.     }
  45.     
  46.     if (prect->g_h < 0) {
  47.         prect->g_h = 0;
  48.     }
  49.  
  50. /*-------------------------------------------------------------------------
  51.  * rc_vadjust - Adjust a VRECT-type rectangle in the x and/or y coordinate.
  52.  *-----------------------------------------------------------------------*/
  53.  
  54. void
  55. rc_vadjust(prect, xadjust, yadjust)
  56.     register VRECT  *prect;
  57.     int             xadjust;
  58.     int             yadjust;
  59. {
  60.     prect->v_x1 -= xadjust;
  61.     prect->v_y1 -= yadjust;
  62.     prect->v_x2 += xadjust;
  63.     prect->v_y2 += yadjust;
  64.     
  65.     if (prect->v_x1 < 0) {
  66.         prect->v_x1 = 0;
  67.     }
  68.     
  69.     if (prect->v_y1 < 0) {
  70.         prect->v_y1 = 0;
  71.     }
  72.     
  73.     if (prect->v_x2 < 0) {
  74.         prect->v_x2 = 0;
  75.     }
  76.     
  77.     if (prect->v_y2 < 0) {
  78.         prect->v_y2 = 0;
  79.     }
  80.  
  81.  
  82.